Create the object for selecting Employee Name
A multi-column list box will be used to display a list of employee names. The person executing the report will select desired names to include in the query. Both employee last name and first name will be contained in the list box.
- Begin by clicking the multi-column list box icon then click anywhere in the design area to place the object.
- In the properties area for this object, change the Multi Select property from no to yes. This will allow the user to select more than one entry.
- Since this object is used later when building an SQL query, give the object a meaningful name such as “EmployeeList” by editing the Object Properties area.
- Double-click on the new object to bring up the following dialog box that allows you to specify which employees are to be included in the query.
- Choose SQL statement to obtain names from the database.
Object Choices Property: Drop-down boxes, list boxes, and multi-column list boxes contain the “choices” property which allows these objects to accept input from the user and display query results as well.
- After selecting “SQL statement”, the following dialog box appears:
- Click the Build Query icon which brings up the Build Query dialog box. Visit this page for more information on the Build Query dialog box.
- Click Show Tables at the upper left which displays the list of tables within the database.
- Double-click the "Employees" table to add it to the query. The Employees table contains the employee names.
- Double-click "last_name" and "first_name" to move them to the query table at the bottom of the screen. Fields that appear in the query on the Visible Fields tab will be included in the SELECT statement.
- We only want to include the employees in the Sales department, so we need to add a condition (WHERE clause) to the SQL query. To add a WHERE clause to obtain only the employees in the Sales Department, click the “Conditional Fields (WHERE)” tab.
- Double-click on dept_id to autofill the and/or, Table, and Field fields.
- Click the “Condition” field, then click the ellipsis button which brings up the SQL Editor. Enter ='dep03' in the text edit box.
- Click OK to continue. The completed condition is shown in the figure below.
- Click the View SQL button at the top of the Build Query dialog box which shows the resulting SQL Query translated by the Visual Design. It shows that only employees within ‘dep03’ will be listed in the multi-column list box.
- Click Next. The next screen shows a preview of the listbox.
- Click Finish.
- To check your work, click the Save button at the top left of the Build Query dialog box to save your work, then click the Test icon to test the form and query design. Note that you can specify how many results you want to display for the test at the bottom of the form. Enter 0 to display all results.
- Note that the multi-column list box is now populated with the list of employees in the Sales Department. Click Close to continue the DataBlock design.
This completes the activities required to create the form that is executed when running the report. The next section in the guide describes how to create the query that will obtain and display information from the database onto the form.